﻿using System;
using System.IO;
using NUnit.Framework;
using Smartkernel.IO;

namespace Smartkernel.NUnitTest.IO
{
    [Category("IO")]
    [TestFixture]
    public class SmartGZipTest
    {
        [Test]
        public void Test()
        {
            //【01】压缩文件（涉及方法：Compress）
            string path1 = @"C:\ZipTest" + DateTime.Now.Ticks.ToString() + ".txt";
            if (!File.Exists(path1))
            {
                using (StreamWriter streamWriter = File.CreateText(path1))
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        streamWriter.WriteLine(DateTime.Now.Ticks.ToString());
                    }
                }
            }
            string path2 = @"C:\ZipTest" + DateTime.Now.Ticks.ToString() + ".zip";
            SmartGZip.Compress(path1, path2);
            Assert.AreEqual(File.Exists(path2), true);

            //【02】解压文件（涉及方法：Decompress）
            string path3 = @"C:\ZipTest" + DateTime.Now.Ticks.ToString() + ".txt";
            SmartGZip.Decompress(path2, path3);
            Assert.AreEqual(File.Exists(path3), true);
            File.Delete(path1);
            File.Delete(path2);
            File.Delete(path3);
        }
    }
}
